var express = require("express");
var router = express.Router();
const jwt = require("jsonwebtoken");

router.get('/token', function (req, res, next) {
    //如果进入该路由，说明请求已经通过了Express-jwt的验证
    //获取发送过来的token并解密
    let token = req.get("Authorization");
    token = token.split(' ')[1];
    const {user} = jwt.verify(token, 'user');
    //返回解密后的数据
    res.send({code:200,user})
})

module.exports = router;
